import { createElement, HTMLAttributes, type FC } from 'react';
import classNames from 'classnames';

import { statisticValueDefaultProps } from './defaultProps';
import type { StatisticValueOptions } from './type';

export interface StatisticValueProps extends StatisticValueOptions, HTMLAttributes<HTMLDivElement> {}

const StatisticValue: FC<StatisticValueProps> = (props) => {
  const { className, text, children, forwardedRef, ...statisticValueProps } = props;

  return createElement(
    'div',
    { ref: forwardedRef, className: classNames({ text }, 'value', className), ...statisticValueProps },
    children,
  );
};

StatisticValue.displayName = 'StatisticValue';
StatisticValue.defaultProps = statisticValueDefaultProps;

export default StatisticValue;
